package zz.note.satoken.controller;

import common.utils.ResultModel;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import zz.note.satoken.entity.SaUserEntity;
import zz.note.satoken.service.SaUserService;

import java.util.Arrays;
import java.util.Map;

/**
 * 
 *
 * @author chenshun
 * @email sunlightcs@gmail.com
 * @date 2022-02-14 17:45:59
 */
@RestController
@RequestMapping("generator/sauser")
public class SaUserController {
    @Autowired
    private SaUserService saUserService;

    /**
     * 列表
     */
    @RequestMapping("/list")
    public ResultModel list(@RequestParam Map<String, Object> params){
        return null;
    }


    /**
     * 信息
     */
    @RequestMapping("/info/{userId}")
    public ResultModel info(@PathVariable("userId") String userId){
		SaUserEntity saUser = saUserService.getById(userId);
        return ResultModel.ok().put("saUser", saUser);
    }

    /**
     * 保存
     */
    @RequestMapping("/save")
    public ResultModel save(@RequestBody SaUserEntity saUser){
		saUserService.save(saUser);
        return ResultModel.ok();
    }

    /**
     * 修改
     */
    @RequestMapping("/update")
    public ResultModel update(@RequestBody SaUserEntity saUser){
		saUserService.updateById(saUser);
        return ResultModel.ok();
    }

    /**
     * 删除
     */
    @RequestMapping("/delete")
    public ResultModel delete(@RequestBody String[] userIds){
		saUserService.removeByIds(Arrays.asList(userIds));
        return ResultModel.ok();
    }

}
